<?php 
$this->layout = '//layouts/admin/blog';
$this->pageTitle = '分类目录';
Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/js/category.add.js', CClientScript::POS_END);
?>
<div class="container container-admin">
    <div class='row'>
        <div class="span3">
            <?php $this->beginWidget('AdminLeftNavWidget');$this->endWidget();?>
        </div>
        <div class='span9'>
            <div class='page-header' style='width:106%'>
                <h2>
                    <span class='fui-new'></span>
                    分类目录
                </h2>
            </div>
            <div class="row">
                <div class='span7 left'>
                    <div class='page-header'>
                        <input style='padding: 2px;' type='text' name='keyword' placeholder='输入搜索词'/>
                        <select class='blog-date'>
                            <option>所有日期</option>
                            <option>1月</option>
                            <option>2月</option>
                        </select>
                        <select class='blog-category'>
                            <option>所有分类</option>
                            <option>PHP</option>
                            <option>JAVA</option>
                        </select>
                        <input type='submit' class='btn' style='padding: 3px 5px;margin-bottom: 10px;' value='筛选分类' />
                    </div>
                    <div class="table" style="min-height:300px">
                        <table class='table table-bordered table-hover'>
                            <thead>
                                <tr>
                                    <td>ID</td>
                                    <td style='min-width: 230px'>名称</td>
                                    <td>所属父类</td>
                                    <td>时间日期</td>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if($models):?>
                                    <?php foreach($models as $k=>$v):?>
                                    <tr>
                                        <td><span class="badge"><?php echo $v->id;?></span></td>
                                        <td>
                                        	<div>
                                        		<?php echo CHtml::encode($v->screen_name);?>
                                    		</div>
                                			<div class="control">
                            					<input type="hidden" value="<?php echo $v->id;?>" name="category-id">
                            					<a class="btn btn-primary btn-control" href='#<?php echo $v->id;?>' data-toggle="modal">编辑</a>
	                                            <a class="btn <?php echo $v->is_delete ? '' : 'btn-primary';?> btn-control" id="category-delete" href='<?php echo Yii::app()->createUrl('admin/category/delete',array('id'=>$v->id));?>'>删除</a>
	                                            <a class="btn <?php echo $v->is_lock ? '' : 'btn-primary';?> btn-control" id="category-lock" href='<?php echo Yii::app()->createUrl('admin/category/lock',array('id'=>$v->id));?>'>锁定</a>
											</div>
                                            <!-- Modal -->
                                            <div id="<?php echo $v->id;?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

                                                <div class="modal-body">
                                                    <div class="data-content-<?php echo $v->id;?>">
                                                        <input type="hidden" name='id' value="<?php echo $v->id;?>" />
                                                        <label>名称</label>
                                                        <input type='text' name='name' style='padding:2px' value="<?php echo $v->name;?>" />
                                                        <label>别名</label>
                                                        <input type='text' name='alias' style='padding:2px' value="<?php echo $v->screen_name;?>" />
                                                    </div>
                                                </div>
                                                <div class="modal-footer">
                                                    <input type="hidden" name='id' id='category-class' value="data-content-<?php echo $v->id;?>" />
                                                    <button class="btn" data-dismiss="modal" aria-hidden="true" style='padding:2px 5px' >关闭</button>
                                                    <button class="btn btn-primary update-category" style='padding:2px 5px' >更新分类</button>
                                                </div>
                                            </div>
                                		</td>
                                        <td><?php echo CHtml::encode($v->parent_category->alias);?></td>
                                        <td><?php echo $v->create_date;?></td>
                                    </tr>
                                    <?php endforeach;?>
                                <?php endif;?>
                            </tbody>
                        </table>
                    </div>
                    <?php if($pages):?>
                        <div class="pagination">
                            <?php 
                            $this->widget('CLinkPager', array(
                                'pages' => $pages,
                                'cssFile'=>'',
                                'firstPageCssClass'=>'hidden',
                                'firstPageLabel'=>'',
                                'internalPageCssClass'=>'',
                                'lastPageCssClass'=>'hidden',
                                'lastPageLabel'=>'',
                                'previousPageCssClass'=>'previous',
                                'prevPageLabel'=>'',
                                'nextPageLabel'=>'',
                                'selectedPageCssClass'=>'active',
                                'hiddenPageCssClass'=>'',
                                'header'=>'',
                                'htmlOptions'=>array(
                                    'class'=>''
                                    )
                                )); 
                            ?>
                        </div>
                    <?php endif;?>
                </div>
                <div class='span2 right'>
                    <div style='margin-top:10px;width:118%'>
                        <div style='border-bottom:1px solid #eee;margin-bottom:10px;width:109%'>
                            <p>
                                <strong>添加新分类目录</strong>
                            </p>
                        </div>
                        <div class="title-fade fade in" style='width:85%'>
                            <label for='category-title'>名称</label>
                            <input name='category-title' id='category-title' type='text' value='' style='padding:2px' placeholder='键入名称'/>
                            <label class='title-error'></label>
                        </div>
                        <div class="alias-fade fade in" style='width:85%'>
                            <label for='category-alias'>别名</label>
                            <input name='category-alias' id='category-allias' type='text' value=''  style='padding:2px' placeholder='键入别名'/>
                            <label class='alias-error'></label>
                        </div>
                        <div class="category-fade fade in" style='width:85%'>
                            <label>父类</label>
                            <select class='' id='category-parent' name=''>
                                <option value=''>选择分类</option>
                                <?php foreach($category as $k=>$v):?>
                                <option value='<?php echo $v->title;?>'><?php echo $v->alias;?></option>
                                <?php endforeach;?>
                            </select>
                            <label class='category-error'></label>
                        </div>
                        <div style='width:85%'>
                            <button class='btn btn-primary' id='tijiao' style='padding:2px 5px;'>添加新分类</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
